<?php
declare (strict_types = 1);

namespace app\admin\validate;

use think\Validate;

class Classroom extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
        'name'           => 'require',
        'min_charges'    => 'require|float',
        //'max_charges'    => 'require|float|gt:min_charges',
        'max_charges'    => 'require|float',
        //'abbreviated'    => 'require',
        'type'           => 'require',
        'level'          => 'require',
        'longitude'      => 'require',
        'latitude'       => 'require',
        'adress'         => 'require',
        'adress_detail'  => 'require',
        'mobile'         => 'require|mobile',
        'contact_people' => 'require',
        'sales_people'   => 'require',
        'desc'           => 'require',
        'nickname'       => 'require',
        'username'       => 'require|length:2, 20|alpha',
        'password'       => 'require|length:6,20',
        'cid'            => 'require',
        'status'         => 'require',
        'agent_uid'      => 'require',
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [
        'name.require'           => '名称不能为空',
        'min_charges.require'    => '收费最低值不能为空',
        'min_charges.float'      => '收费最低值填写错误',
        'max_charges.require'    => '收费最高值不能为空',
        'max_charges.float'      => '收费最高值填写错误',
        //'max_charges.gt'         => '收费最高值不能小于消费最低值',
        //'abbreviated.require'    => '教室简称不能为空',
        'type.require'           => '请选择教室类型',
        'level.require'          => '请选择教室等级',
        'longitude.require'      => '教室经度不能为空',
        'latitude.require'       => '教室纬度不能为空',
        'adress.require'         => '请选择教室所在省市区',
        'adress_detail.require'  => '教室详细地址不能为空',
        'mobile.require'         => '联系电话不能为空',
        'mobile.mobile'          => '联系电话格式有误',
        'contact_people.require' => '联系人不能为空',
        'sales_people.require'   => '销售代表不能为空',
        'desc.require'           => '教室简介不能为空',
        'nickname.require'       => '教师姓名不能为空',
        'username.require'       => '教师登录账号不能为空',
        'username.alpha'         => '教师登录账号只能为字母组合',
        'username.length'        => '教师登录账号长度为2-20',
        'password.require'       => '教师登录密码不能为空',
        'password.length'        => '教师登录密码长度为6-20',
        'cid.require'            => '请选择所属教室',
        'status.require'         => '请选择状态',
        'agent_uid.require'      => '请选择教室代理员',
    ];

    /**
     * 定义情景信息
     *
     * @var array
     */
    protected $scene = [
        'grade'        => ['name','min_charges', 'max_charges', 'status'],
        'type'         => ['name', 'status'],
        'classroom'    => ['name', 'type', 'level', 'adress', 'adress_detail', 'mobile', 'contact_people', 'contact_people', 'sales_people', 'desc', 'status', 'agent_uid'],
        'teachers'     => ['nickname', 'username', 'password', 'cid', 'status'],
        'teacher'      => ['nickname', 'username', 'password', 'status'],
        'no_teachers'  => ['nickname', 'username', 'cid', 'status'],
        'no_teacher'   => ['nickname', 'username', 'status'],
    ];
}
